﻿<Workspace x:Name="grammar_ERG"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:sys="clr-namespace:System;assembly=mscorlib"
  xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
  xmlns="clr-namespace:agree;assembly=agree-sys"
  xmlns:cfg="clr-namespace:agree.configuration;assembly=agree-sys"
  xmlns:tsdb="clr-namespace:agree.itsdb;assembly=agree-sys"
  xmlns:semi="clr-namespace:agree.semi;assembly=agree-sys">

    <Workspace.DefaultDirectories>
        <StringItem>grammars</StringItem>
        <StringItem>grammars\erg</StringItem>
    </Workspace.DefaultDirectories>

    <Grammar x:Name="ERG"
             DisplayName="English Resource Grammar"
             Author="Flickinger (2000). in Flickinger, Oepen, Tsujii, Uszkoreit, eds."
             ItemCulture="en-US">
        <Grammar.AgreeConfig>
            <cfg:AgreeConfig x:Name="ERG_config" Loader="{cfg:PetConfigLoader pet/english.set}" />
        </Grammar.AgreeConfig>
    </Grammar>

    <PropertyRef Item="{x:Reference ERG_config}" Path="Parser.Chart.NonIdiomRoot" Target="root_non_idiom" />

    <TdlGroup x:Name="ERG_TdlGroup">
        <!--
            the type of the following property is 'TdlLetterSets', which is a XAML dictionary of Char -to- LetterSet. You
            can add items directly to the default instance, as shown here. If you instead instantiate and assign a new 
            TdlLetterSets, its contents will be copied into the default instance. Exact duplicates are ignored, but 
            attempting to assign a new value to an existing key will fail. An effort is made to copy its properties 
            over to the default instance but this is hazy territory (are x:Name values registered on a namescope, for 
            example?). Note that there is no way to delete a letter set once it is added.
            -->
        <TdlGroup.TdlLetterSets>
            <LetterSet Identifier="c" Letters="bdfgklmnprstz" />
            <LetterSet Identifier="s" Letters="abcdefghijklmnopqrtuvwxyz05_/" />
            <LetterSet Identifier="t" Letters="bcdfghjklmnpqrstvwxyz" />
            <LetterSet Identifier="v" Letters="aeiou" />
            <LetterSet Identifier="."><![CDATA[abcdefghijklmnopqrstuvwxyzåøöáéíóúìñABCDEFGHIJKLMNOPQRSTUVWXYZÅØÖÉÌ0123456789[](){}|>/_-…%`”"'’?!#+¦σΩÅØµ™°º]]></LetterSet>
            <LetterSet Identifier="p"><![CDATA[abcdefghijklmnopqrstuvwxyzåøöáéíóúìµñABCDEFGHIJKLMNOPQRSTUVWXYZÅØÖÉÌ0123456789,.?![](){}|>/_%”"'’#+¦σΩÅØ®…™°ºβ*]]></LetterSet>
            <LetterSet Identifier="q"><![CDATA[abcdefghijklmnopqrstuvwxyzåøöáéíóúìñABCDEFGHIJKLMNOPQRSTUVWXYZÅØÖÉÌ0123456789,.?!()[]{}|>:/_-%`”"'’#+¦σΩ…µ™°º]]></LetterSet>
            <LetterSet Identifier="f"><![CDATA[abcdefghijklmnopqrstuvwxyzåøöáéíóúìñABCDEFGHIJKLMNOPQRSTUVWXYZÅØÖÉÌ0123456789[]“"‘'#+¦$=()[]{}|<_\-.,ÅØ½…µ™°ºβ]]></LetterSet>
            <LetterSet Identifier="b" Letters="!" />
        </TdlGroup.TdlLetterSets>

        <Tdl Content="{ReadFile fundamentals.tdl}" />
        <Tdl Content="{ReadFile lextypes.tdl}" />
        <Tdl Content="{ReadFile tmt.tdl}" />
        <Tdl Content="{ReadFile lfr.tdl}"             TdlType="LexicalFilteringRule" />
        <Tdl Content="{ReadFile syntax.tdl}" />
        <Tdl Content="{ReadFile ctype.tdl}" />
        <Tdl Content="{ReadFile lexrules.tdl}"/>
        <Tdl Content="{ReadFile auxverbs.tdl}" />
        <Tdl Content="{ReadFile letypes.tdl}" />
        <!--<Tdl Content="{ReadFile dts.tdl}" />
        <Tdl Content="{ReadFile delims.tdl}" />-->

        <Tdl Content="{ReadFile mtr.tdl}" />

        <Tdl Content="{ReadFile lexicon.tdl}"         TdlType="LexicalEntry" />
        <Tdl Content="{ReadFile grammars/erg-agree/lexicon-aux.tdl}" TdlType="LexicalEntry" />
        <Tdl Content="{ReadFile gle.tdl}"             TdlType="GenericLexicalEntry" />
        <Tdl Content="{ReadFile constructions.tdl}"   TdlType="SyntaxRule" />
        <!-- Rules with morphology are submitted as LexicalRules; detection of possible spelling-change is automatic -->
        <Tdl Content="{ReadFile inflr.tdl}"           TdlType="LexicalRule" />
        <Tdl Content="{ReadFile lexrinst.tdl}"        TdlType="LexicalRule" />
        <!-- Rules with morphology are submitted as LexicalRules; detection of possible spelling-change is automatic -->
        <Tdl Content="{ReadFile inflr-pnct.tdl}"      TdlType="LexicalRule" />
        <Tdl Content="{ReadFile parse-nodes.tdl}"     TdlType="NodeLabel" />
        <Tdl Content="{ReadFile roots.tdl}"           TdlType="StartSymbol" />
        <Tdl Content="{ReadFile trigger.mtr}"         TdlType="TriggerRule" />

    </TdlGroup >

    <TdlGroup x:Name="ERG_TmrGroup">
        <Tdl Content="{ReadFile tmr/ner.tdl}"         TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/gml.tdl}"         TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/ptb.tdl}"         TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/spelling.tdl}"    TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/ne1.tdl}"         TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/split.tdl}"       TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/ne2.tdl}"         TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/class.tdl}"       TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/ne3.tdl}"         TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/punctuation.tdl}" TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/pos.tdl}"         TdlType="TokenMappingRule" />
        <Tdl Content="{ReadFile tmr/finis.tdl}"       TdlType="TokenMappingRule" />
    </TdlGroup>

    <TdlTokenizerFactory x:Name="tok_functor"
                         AgreeConfig="{x:Reference ERG_config}"
                         TdlLetterSets="{PathRef {x:Reference ERG_TdlGroup}, TdlLetterSets}" />

    <TypeDictionary x:Name="ERG_td" Grammar="{x:Reference ERG}" />

    <TypeLattice x:Name="ERG_bcpo">
        <TypeGraphFinalizer>
            <TypeDictionaryLoader TypeDictionary="{x:Reference ERG_td}">
                <TdlConstraintGrouper TdlType="Type">
                    <TdlHashAggregator Functor="{x:Reference tok_functor}">
                        <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.Type}}">
                            <x:Reference Name="ERG_TdlGroup" />
                        </Where>
                    </TdlHashAggregator>
                </TdlConstraintGrouper>
            </TypeDictionaryLoader>
        </TypeGraphFinalizer>
    </TypeLattice>

    <FeatMgr x:Name="ERG_ftm" TypeLattice="{x:Reference ERG_bcpo}" />

    <GlbCache x:Name="ERG_glbc" FeatMgr="{x:Reference ERG_ftm}" />

    <TypeUtils x:Name="ERG_tu" GlbCache="{x:Reference ERG_glbc}" />

    <Isometrics x:Name="ERG_im" TypeUtils="{x:Reference ERG_tu}" />

    <TokenMappingGeometry x:Name="ERG_tmg" Isometrics="{x:Reference ERG_im}" />

    <TfsUnifier x:Name="ERG_u" Isometrics="{x:Reference ERG_im}" />

    <MrsManager x:Name="ERG_mrsm" Isometrics="{x:Reference ERG_im}" />

    <PropertyRef Item="{x:Reference ERG}" Path="SemI">
        <semi:SemI x:Name="ERG_semi" PredicateArgs="{semi:PredicateArgsLoader etc\\core.smi}">
            <semi:SemI.Vpm>
                <semi:Vpm Loader="{semi:VpmLoader semi.vpm}" />
            </semi:SemI.Vpm>
        </semi:SemI>
    </PropertyRef>

    <EntryMgr x:Name="ERG_em"
              TfsUnifier="{x:Reference ERG_u}"
              MrsManager="{x:Reference ERG_mrsm}"
              TokenMappingGeometry="{x:Reference ERG_tmg}"
              DefaultTokenizer="{x:Static SplitTokenizer.SpaceCharTokenizer}">

        <EntryMgr.SyntaxRuleTokenGroups>
            <TdlConstraintGrouper TdlType="SyntaxRule">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.SyntaxRule}}" >
                        <x:Reference Name="ERG_TdlGroup" />
                    </Where>
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.SyntaxRuleTokenGroups>

        <EntryMgr.LexicalRuleTokenGroups>
            <TdlConstraintGrouper TdlType="LexicalRule">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.LexicalRule}}">
                        <x:Reference Name="ERG_TdlGroup" />
                    </Where>
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.LexicalRuleTokenGroups>

        <EntryMgr.LexicalEntryTokenGroups>
            <TdlConstraintGrouper TdlType="LexicalEntry">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.LexicalEntry}}">
                        <x:Reference Name="ERG_TdlGroup" />
                    </Where>
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.LexicalEntryTokenGroups>

        <EntryMgr.GenericLexicalEntryTokenGroups>
            <TdlConstraintGrouper TdlType="GenericLexicalEntry">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.GenericLexicalEntry}}">
                        <x:Reference Name="ERG_TdlGroup" />
                    </Where>
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.GenericLexicalEntryTokenGroups>

        <EntryMgr.NodeLabelTokenGroups>
            <TdlConstraintGrouper TdlType="NodeLabel">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.NodeLabel}}">
                        <x:Reference Name="ERG_TdlGroup" />
                    </Where>
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.NodeLabelTokenGroups>

        <EntryMgr.TriggerRuleTokenGroups>
            <TdlConstraintGrouper TdlType="TriggerRule">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.TriggerRule}}">
                        <x:Reference Name="ERG_TdlGroup" />
                    </Where>
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.TriggerRuleTokenGroups>

        <EntryMgr.StartSymbolTokenGroups>
            <TdlConstraintGrouper TdlType="StartSymbol">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.StartSymbol}}">
                        <x:Reference Name="ERG_TdlGroup" />
                    </Where>
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.StartSymbolTokenGroups>

        <!-- Here, for the token mapping rules, we demonstrate an alternative to using the 'Where' markup 
            extension to select the tokens of a certain type (as for the entry types shown above). Instead, 
            we just grab all of the tokens from a dedicated TdlGroup we defined above ('ERG_TmrGroup') -->
        <EntryMgr.TokenMappingRuleTokenGroups>
            <TdlConstraintGrouper TdlType="TokenMappingRule">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <x:Reference Name="ERG_TmrGroup" />
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.TokenMappingRuleTokenGroups>

        <EntryMgr.LexicalFilteringRuleTokenGroups>
            <TdlConstraintGrouper TdlType="LexicalFilteringRule">
                <TdlHashAggregator Functor="{x:Reference tok_functor}">
                    <Where x:TypeArguments="Tdl" Functor="{TdlTypePred {x:Static TdlType.LexicalFilteringRule}}">
                        <x:Reference Name="ERG_TdlGroup" />
                    </Where>
                </TdlHashAggregator>
            </TdlConstraintGrouper>
        </EntryMgr.LexicalFilteringRuleTokenGroups>

    </EntryMgr>

    <PropertyRef Item="{x:Reference ERG_config}" Path="Generator.Chart.IgnoreRules">
        <ReadFileLines Filename="lkb/nogen-rules.set" />
    </PropertyRef>

    <NodeLabeler x:Name="ERG_nl"
                 EntryMgr="{x:Reference ERG_em}"
                 TfsUnifier="{x:Reference ERG_u}" />

    <TriggerRuleMgr x:Name="ERG_trm"
                 EntryMgr="{x:Reference ERG_em}" />

    <RuleCompatibiltyCache EntryMgr="{x:Reference ERG_em}" Enable="True" />

    <Irregulars x:Name="ERG_irregs"
                EntryMgr="{x:Reference ERG_em}"
                Items="{IrregsReader irregs.tab}" />

    <MorphologyRules x:Name="ERG_mph"
                EntryMgr="{x:Reference ERG_em}"
                Irregulars="{x:Reference ERG_irregs}" />

    <Lexicon x:Name="ERG_lex"
             EntryMgr="{x:Reference ERG_em}"
             MorphologyRules="{x:Reference ERG_mph}" />

    <QuickCheck x:Name="ERG_qc"
                TypeUtils="{x:Reference ERG_tu}"
                Paths="{ReadFileLines grammars/erg-agree/erg-qc-paths.txt}" />

</Workspace>
